package org.gpp.proj1.bone;


import junit.framework.TestCase;

public class KeyframeIntervalTest extends TestCase {

	/*
	 * Test method for 'org.gpp.proj1.bone.KeyframeInterval.KeyframeInterval(int, int)'
	 */
	public void testKeyframeInterval() {
		// Beginning must come -before- the start
		try {
			new KeyframeInterval( 4, 2 );
			fail();
		} catch( AssertionError e ) {
			// expected error
		}
		
		// Negative a values aren't allowed 
		try {
			new KeyframeInterval( -1, 2 );
			fail();
		} catch( AssertionError e ) {
			// expected error
		}
		
		try {
			new KeyframeInterval( -5, -5 );
			fail();
		} catch( AssertionError e ) {
			// expected error
		}
		
		// Valid constructs
		try {
			new KeyframeInterval( 0, 0 );
		} catch( AssertionError e ) {
			fail();
		}
		
		try {
			new KeyframeInterval( 0, 100 );
		} catch( AssertionError e ) {
			fail();
		}
	}

	/*
	 * Test method for 'org.gpp.proj1.bone.KeyframeInterval.getBegin()'
	 */
	public void testGetBegin() {
		KeyframeInterval interval = new KeyframeInterval( 0, 100 );
		
		assertEquals( 0, interval.getBegin() );
		
		interval = new KeyframeInterval( 99, 100 );
		
		assertEquals( 99, interval.getBegin() );
	}

	/*
	 * Test method for 'org.gpp.proj1.bone.KeyframeInterval.getEnd()'
	 */
	public void testGetEnd() {
		KeyframeInterval interval = new KeyframeInterval( 0, 100 );
		
		assertEquals( 100, interval.getEnd() );
		
		interval = new KeyframeInterval( 98, 99 );
		
		assertEquals( 99, interval.getEnd() );
	}

	/*
	 * Test method for 'org.gpp.proj1.bone.KeyframeInterval.equals(Object)'
	 */
	public void testEqualsObject() {
		assertEquals( new KeyframeInterval( 0, 0 ), new KeyframeInterval( 0, 0 ) );
		assertEquals( new KeyframeInterval( 0, 99 ), new KeyframeInterval( 0, 99 ) );
		assertEquals( new KeyframeInterval( 99, 99 ), new KeyframeInterval( 99, 99 ) );
		
		assertFalse( new KeyframeInterval( 0, 0 ).equals( new KeyframeInterval( 0, 1 ) ) );
		assertFalse( new KeyframeInterval( 0, 5 ).equals( new KeyframeInterval( 5, 8 ) ) );
	}

}
